<html>
<head>
    <title>SystemUiHiderHoneycomb.java</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
        .ln { color: rgb(0,0,0); font-weight: normal; font-style: normal; }
        .s0 { color: rgb(0,0,128); font-weight: bold; }
        .s1 { }
        .s2 { color: rgb(128,128,128); font-style: italic; }
        .s3 { color: rgb(128,128,128); font-weight: bold; font-style: italic; }
        .s4 { color: rgb(0,0,255); }
    </style>
</head>
<BODY BGCOLOR="#ffffff">
<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#C0C0C0">
    <TR>
        <TD>
            <CENTER>
                <FONT FACE="Arial, Helvetica" COLOR="#000000">
                    SystemUiHiderHoneycomb.java</FONT>
            </center>
        </TD>
    </TR>
</TABLE>
<pre>

<a name="l1"><span class="ln">1    </span></a><span class="s0">package </span><span class="s1">com.ibr.ticketmanagement.app.util; 
<a name="l2"><span class="ln">2    </span></a> 
<a name="l3"><span class="ln">3    </span></a></span><span class="s0">import </span><span
        class="s1">android.annotation.TargetApi;
<a name="l4"><span class="ln">4    </span></a></span><span class="s0">import </span><span
        class="s1">android.app.Activity;
<a name="l5"><span class="ln">5    </span></a></span><span class="s0">import </span><span
        class="s1">android.os.Build;
<a name="l6"><span class="ln">6    </span></a></span><span class="s0">import </span><span
        class="s1">android.view.View;
<a name="l7"><span class="ln">7    </span></a></span><span class="s0">import </span><span
        class="s1">android.view.WindowManager;
<a name="l8"><span class="ln">8    </span></a> 
<a name="l9"><span class="ln">9    </span></a></span><span class="s2">/** 
<a name="l10"><span class="ln">10   </span></a> * An API 11+ implementation of {</span><span
        class="s3">@link <a href="SystemUiHider.java.html">SystemUiHider</a></span><span class="s2">}. Uses APIs available in
<a name="l11"><span class="ln">11   </span></a> * Honeycomb and later (specifically {</span><span
        class="s3">@link </span><span class="s2">View#setSystemUiVisibility(int)}) to
<a name="l12"><span class="ln">12   </span></a> * show and hide the system UI. 
<a name="l13"><span class="ln">13   </span></a> */</span><span class="s1"> 
<a name="l14"><span class="ln">14   </span></a>@TargetApi(Build.VERSION_CODES.HONEYCOMB) 
<a name="l15"><span class="ln">15   </span></a></span><span class="s0">public class </span><span
        class="s1">SystemUiHiderHoneycomb </span><span class="s0">extends <a
        href="SystemUiHiderBase.java.html">SystemUiHiderBase</a> </span><span class="s1">{
<a name="l16"><span class="ln">16   </span></a>    </span><span class="s2">/** 
<a name="l17"><span class="ln">17   </span></a>     * Flags for {</span><span
        class="s3">@link </span><span class="s2">View#setSystemUiVisibility(int)} to use when showing the
<a name="l18"><span class="ln">18   </span></a>     * system UI. 
<a name="l19"><span class="ln">19   </span></a>     */</span><span class="s1"> 
<a name="l20"><span class="ln">20   </span></a>    </span><span class="s0">private int </span><span
        class="s1">mShowFlags;
<a name="l21"><span class="ln">21   </span></a> 
<a name="l22"><span class="ln">22   </span></a>    </span><span class="s2">/** 
<a name="l23"><span class="ln">23   </span></a>     * Flags for {</span><span
        class="s3">@link </span><span class="s2">View#setSystemUiVisibility(int)} to use when hiding the
<a name="l24"><span class="ln">24   </span></a>     * system UI. 
<a name="l25"><span class="ln">25   </span></a>     */</span><span class="s1"> 
<a name="l26"><span class="ln">26   </span></a>    </span><span class="s0">private int </span><span
        class="s1">mHideFlags;
<a name="l27"><span class="ln">27   </span></a> 
<a name="l28"><span class="ln">28   </span></a>    </span><span class="s2">/** 
<a name="l29"><span class="ln">29   </span></a>     * Flags to test against the first parameter in 
<a name="l30"><span class="ln">30   </span></a>     * {</span><span class="s3">@link </span><span
        class="s2">android.view.View.OnSystemUiVisibilityChangeListener#onSystemUiVisibilityChange(int)}
<a name="l31"><span class="ln">31   </span></a>     * to determine the system UI visibility state. 
<a name="l32"><span class="ln">32   </span></a>     */</span><span class="s1"> 
<a name="l33"><span class="ln">33   </span></a>    </span><span class="s0">private int </span><span
        class="s1">mTestFlags;
<a name="l34"><span class="ln">34   </span></a> 
<a name="l35"><span class="ln">35   </span></a>    </span><span class="s2">/** 
<a name="l36"><span class="ln">36   </span></a>     * Whether or not the system UI is currently visible. This is cached from 
<a name="l37"><span class="ln">37   </span></a>     * {</span><span class="s3">@link </span><span
        class="s2">android.view.View.OnSystemUiVisibilityChangeListener}.
<a name="l38"><span class="ln">38   </span></a>     */</span><span class="s1"> 
<a name="l39"><span class="ln">39   </span></a>    </span><span
        class="s0">private boolean </span><span class="s1">mVisible = </span><span
        class="s0">true</span><span class="s1">;
<a name="l40"><span class="ln">40   </span></a> 
<a name="l41"><span class="ln">41   </span></a>    </span><span class="s2">/** 
<a name="l42"><span class="ln">42   </span></a>     * Constructor not intended to be called by clients. Use 
<a name="l43"><span class="ln">43   </span></a>     * {</span><span class="s3">@link <a
        href="SystemUiHider.java.html">SystemUiHider</a></span><span class="s2">#getInstance} to obtain an instance.
<a name="l44"><span class="ln">44   </span></a>     */</span><span class="s1"> 
<a name="l45"><span class="ln">45   </span></a>    </span><span class="s0">protected </span><span
        class="s1">SystemUiHiderHoneycomb(Activity activity, View anchorView, </span><span
        class="s0">int </span><span class="s1">flags) {
<a name="l46"><span class="ln">46   </span></a>        </span><span class="s0">super</span><span
        class="s1">(activity, anchorView, flags);
<a name="l47"><span class="ln">47   </span></a> 
<a name="l48"><span class="ln">48   </span></a>        mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE; 
<a name="l49"><span class="ln">49   </span></a>        mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; 
<a name="l50"><span class="ln">50   </span></a>        mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; 
<a name="l51"><span class="ln">51   </span></a> 
<a name="l52"><span class="ln">52   </span></a>        </span><span class="s0">if </span><span
        class="s1">((mFlags &amp; FLAG_FULLSCREEN) != </span><span class="s4">0</span><span
        class="s1">) {
<a name="l53"><span class="ln">53   </span></a>            </span><span class="s2">// If the client requested fullscreen, add flags relevant to hiding</span><span
        class="s1">
<a name="l54"><span class="ln">54   </span></a>            </span><span class="s2">// the status bar. Note that some of these constants are new as of</span><span
        class="s1">
<a name="l55"><span class="ln">55   </span></a>            </span><span class="s2">// API 16 (Jelly Bean). It is safe to use them, as they are inlined</span><span
        class="s1">
<a name="l56"><span class="ln">56   </span></a>            </span><span class="s2">// at compile-time and do nothing on pre-Jelly Bean devices.</span><span
        class="s1">
<a name="l57"><span class="ln">57   </span></a>            mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; 
<a name="l58"><span class="ln">58   </span></a>            mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
<a name="l59"><span class="ln">59   </span></a>                    | View.SYSTEM_UI_FLAG_FULLSCREEN; 
<a name="l60"><span class="ln">60   </span></a>        } 
<a name="l61"><span class="ln">61   </span></a> 
<a name="l62"><span class="ln">62   </span></a>        </span><span class="s0">if </span><span
        class="s1">((mFlags &amp; FLAG_HIDE_NAVIGATION) != </span><span class="s4">0</span><span
        class="s1">) {
<a name="l63"><span class="ln">63   </span></a>            </span><span class="s2">// If the client requested hiding navigation, add relevant flags.</span><span
        class="s1">
<a name="l64"><span class="ln">64   </span></a>            mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; 
<a name="l65"><span class="ln">65   </span></a>            mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
<a name="l66"><span class="ln">66   </span></a>                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 
<a name="l67"><span class="ln">67   </span></a>            mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 
<a name="l68"><span class="ln">68   </span></a>        } 
<a name="l69"><span class="ln">69   </span></a>    } 
<a name="l70"><span class="ln">70   </span></a> 
<a name="l71"><span class="ln">71   </span></a>    </span><span class="s2">/** {</span><span
        class="s3">@inheritDoc</span><span class="s2">} */</span><span class="s1">
<a name="l72"><span class="ln">72   </span></a>    @Override 
<a name="l73"><span class="ln">73   </span></a>    </span><span class="s0">public void </span><span
        class="s1">setup() {
<a name="l74"><span class="ln">74   </span></a>        mAnchorView.setOnSystemUiVisibilityChangeListener(mSystemUiVisibilityChangeListener); 
<a name="l75"><span class="ln">75   </span></a>    } 
<a name="l76"><span class="ln">76   </span></a> 
<a name="l77"><span class="ln">77   </span></a>    </span><span class="s2">/** {</span><span
        class="s3">@inheritDoc</span><span class="s2">} */</span><span class="s1">
<a name="l78"><span class="ln">78   </span></a>    @Override 
<a name="l79"><span class="ln">79   </span></a>    </span><span class="s0">public void </span><span
        class="s1">hide() {
<a name="l80"><span class="ln">80   </span></a>        mAnchorView.setSystemUiVisibility(mHideFlags); 
<a name="l81"><span class="ln">81   </span></a>    } 
<a name="l82"><span class="ln">82   </span></a> 
<a name="l83"><span class="ln">83   </span></a>    </span><span class="s2">/** {</span><span
        class="s3">@inheritDoc</span><span class="s2">} */</span><span class="s1">
<a name="l84"><span class="ln">84   </span></a>    @Override 
<a name="l85"><span class="ln">85   </span></a>    </span><span class="s0">public void </span><span
        class="s1">show() {
<a name="l86"><span class="ln">86   </span></a>        mAnchorView.setSystemUiVisibility(mShowFlags); 
<a name="l87"><span class="ln">87   </span></a>    } 
<a name="l88"><span class="ln">88   </span></a> 
<a name="l89"><span class="ln">89   </span></a>    </span><span class="s2">/** {</span><span
        class="s3">@inheritDoc</span><span class="s2">} */</span><span class="s1">
<a name="l90"><span class="ln">90   </span></a>    @Override 
<a name="l91"><span class="ln">91   </span></a>    </span><span
        class="s0">public boolean </span><span class="s1">isVisible() {
<a name="l92"><span class="ln">92   </span></a>        </span><span class="s0">return </span><span
        class="s1">mVisible;
<a name="l93"><span class="ln">93   </span></a>    } 
<a name="l94"><span class="ln">94   </span></a> 
<a name="l95"><span class="ln">95   </span></a>    </span><span class="s0">private </span><span
        class="s1">View.OnSystemUiVisibilityChangeListener mSystemUiVisibilityChangeListener
<a name="l96"><span class="ln">96   </span></a>            = </span><span
        class="s0">new </span><span class="s1">View.OnSystemUiVisibilityChangeListener() {
<a name="l97"><span class="ln">97   </span></a>        @Override 
<a name="l98"><span class="ln">98   </span></a>        </span><span
        class="s0">public void </span><span class="s1">onSystemUiVisibilityChange(</span><span
        class="s0">int </span><span class="s1">vis) {
<a name="l99"><span class="ln">99   </span></a>            </span><span class="s2">// Test against mTestFlags to see if the system UI is visible.</span><span
        class="s1">
<a name="l100"><span class="ln">100  </span></a>            </span><span class="s0">if </span><span
        class="s1">((vis &amp; mTestFlags) != </span><span class="s4">0</span><span class="s1">) {
<a name="l101"><span class="ln">101  </span></a>                </span><span
        class="s0">if </span><span class="s1">(Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.JELLY_BEAN) {
<a name="l102"><span class="ln">102  </span></a>                    </span><span class="s2">// Pre-Jelly Bean, we must manually hide the action bar</span><span
        class="s1">
<a name="l103"><span class="ln">103  </span></a>                    </span><span class="s2">// and use the old window flags API.</span><span
        class="s1">
<a name="l104"><span class="ln">104  </span></a>                    mActivity.getActionBar().hide(); 
<a name="l105"><span class="ln">105  </span></a>                    mActivity.getWindow().setFlags( 
<a name="l106"><span class="ln">106  </span></a>                            WindowManager.LayoutParams.FLAG_FULLSCREEN, 
<a name="l107"><span class="ln">107  </span></a>                            WindowManager.LayoutParams.FLAG_FULLSCREEN); 
<a name="l108"><span class="ln">108  </span></a>                } 
<a name="l109"><span class="ln">109  </span></a> 
<a name="l110"><span class="ln">110  </span></a>                </span><span class="s2">// Trigger the registered listener and cache the visibility</span><span
        class="s1">
<a name="l111"><span class="ln">111  </span></a>                </span><span
        class="s2">// state.</span><span class="s1">
<a name="l112"><span class="ln">112  </span></a>                mOnVisibilityChangeListener.onVisibilityChange(</span><span
        class="s0">false</span><span class="s1">);
<a name="l113"><span class="ln">113  </span></a>                mVisible = </span><span class="s0">false</span><span
        class="s1">;
<a name="l114"><span class="ln">114  </span></a> 
<a name="l115"><span class="ln">115  </span></a>            } </span><span
        class="s0">else </span><span class="s1">{
<a name="l116"><span class="ln">116  </span></a>                mAnchorView.setSystemUiVisibility(mShowFlags); 
<a name="l117"><span class="ln">117  </span></a>                </span><span
        class="s0">if </span><span class="s1">(Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.JELLY_BEAN) {
<a name="l118"><span class="ln">118  </span></a>                    </span><span class="s2">// Pre-Jelly Bean, we must manually show the action bar</span><span
        class="s1">
<a name="l119"><span class="ln">119  </span></a>                    </span><span class="s2">// and use the old window flags API.</span><span
        class="s1">
<a name="l120"><span class="ln">120  </span></a>                    mActivity.getActionBar().show(); 
<a name="l121"><span class="ln">121  </span></a>                    mActivity.getWindow().setFlags( 
<a name="l122"><span class="ln">122  </span></a>                            </span><span class="s4">0</span><span
        class="s1">,
<a name="l123"><span class="ln">123  </span></a>                            WindowManager.LayoutParams.FLAG_FULLSCREEN); 
<a name="l124"><span class="ln">124  </span></a>                } 
<a name="l125"><span class="ln">125  </span></a> 
<a name="l126"><span class="ln">126  </span></a>                </span><span class="s2">// Trigger the registered listener and cache the visibility</span><span
        class="s1">
<a name="l127"><span class="ln">127  </span></a>                </span><span
        class="s2">// state.</span><span class="s1">
<a name="l128"><span class="ln">128  </span></a>                mOnVisibilityChangeListener.onVisibilityChange(</span><span
        class="s0">true</span><span class="s1">);
<a name="l129"><span class="ln">129  </span></a>                mVisible = </span><span class="s0">true</span><span
        class="s1">;
<a name="l130"><span class="ln">130  </span></a>            } 
<a name="l131"><span class="ln">131  </span></a>        } 
<a name="l132"><span class="ln">132  </span></a>    }; 
<a name="l133"><span class="ln">133  </span></a>} 
<a name="l134"><span class="ln">134  </span></a></span></pre>
</body>
</html>